#ifndef __TM1640_H__
#define __TM1640_H__
#include "GPIO.h"

#define I2C1_SDA_GPIO_PORT           GPIO_P0
#define I2C1_SDA_GPIO_PIN            GPIO_Pin_4
#define I2C1_SCK_GPIO_PORT           GPIO_P0
#define I2C1_SCK_GPIO_PIN            GPIO_Pin_3

#define I2C1_SDA_HIGH()              {P04 = 1;}
#define I2C1_SDA_LOW()               {P04 = 0;}
#define I2C1_SCK_HIGH()              {P03 = 1;}
#define I2C1_SCK_LOW()               {P03 = 0;}

/* 数据操作命令 */
#define TM1640_CMD_DATA_FIXED       (0x40)      //固定地址
#define TM1640_CMD_DATA_PLUS        (0x44)      //地址自动+1

/* 背光亮度 */
#define TM1640_CMD_LIGHT_OFF        (0X80)
#define TM1640_CMD_LIGHT_1_16       (0X89)
#define TM1640_CMD_LIGHT_2_16       (0X8A)
#define TM1640_CMD_LIGHT_4_16       (0X8B)
#define TM1640_CMD_LIGHT_10_16      (0X8C)
#define TM1640_CMD_LIGHT_12_16      (0X8D)
#define TM1640_CMD_LIGHT_13_16      (0X8E)
#define TM1640_CMD_LIGHT_14_16      (0X8F)

void tm1640_init(void);
void tm1640_set_output(u8 *buf, u8 len);
void tm1640_set_luminance(u8 cmd);

#endif/* __TM1640_H__ */